package edu.office.applicationRepository;


import edu.office.entities.Scheduleclass;
import edu.office.tools.EOMessage;
import edu.office.tools.EOMessage1;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Named;

import java.util.List;


@Named("scheduleclassRepositoryA")
@ApplicationScoped
public class ScheduleclassRepository extends ApplicationCommonRepository<Scheduleclass>{
    public String myCreate(Scheduleclass scheduleclass) {
        List<Scheduleclass> existedList = find("NAME", scheduleclass.getNAME()).firstResult();
        if (existedList.isEmpty()) {
            create(scheduleclass);
            return EOMessage.getEOMessageENUM(EOMessage1.Succeed);
        } else {
            return scheduleclass.getNAME() + ":" + EOMessage.getEOMessageENUM(EOMessage1.Already_Exist);
        }
    }
}
